package org.budo.druid.filter.wall;

import org.springframework.beans.factory.FactoryBean;

import com.alibaba.druid.filter.Filter;
import com.alibaba.druid.wall.WallConfig;
import com.alibaba.druid.wall.WallFilter;

/**
 * @author limingwei
 */
public class BudoWallFilterFactoryBean implements FactoryBean<Filter> {
    @Override
    public Filter getObject() throws Exception {
        return this.newWallFilter();
    }

    public Filter newWallFilter() {
        WallConfig config = new WallConfig();
        config.setCallAllow(false); // 不允许通过jdbc的call语法调用存储过程
        config.setShowAllow(true); // 允许 show

        BudoWallFilter wallFilter = new BudoWallFilter();
        wallFilter.setConfig(config);
        return wallFilter;
    }

    @Override
    public Class<?> getObjectType() {
        return WallFilter.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}